%   Initialization
clear; close all; clc;
%   The size of input layer
input_layer_size  = 400;
%   The number of the labels
num_labels = 10;
fprintf('Loading and Visualizing Data ...\n');
%   Load the data from the Mat --- X, y
load('data1.mat');
%   The number of the training examples
m = size(X, 1);
%   The random indices of the training examples
rand_indices = randperm(m);
%   Display the randomly selected 100 data from the training examples
displayData(X(rand_indices(1:100), :));
%   Pause the program
fprintf('Program paused. Press any key to continue.\n'); pause;
fprintf('Training One-vs-All Logistic Regression...\n');
%   Set the lambda
lambda = 0.1;
%   Train the thetas
[all_theta] = oneVsAll(X, y, num_labels, lambda);
%   Pause the program
fprintf('Program paused. Press any key to continue.\n'); pause;
%   Get the predictions
predictions = predictOneVsAll(all_theta, X);
fprintf('Training Set Accuracy: %f\n', mean(double(predictions == y)) * 100);
